@extends('admin.adminbase')
@section('content')
    <section class="hbox stretch">
        @include("admin.public.left")
        <aside>
            <section class="vbox">
                <header class="header bg-white b-b clearfix">
                    <form class="talbe-search" method="get" action="{{url('admin/card/lockAgree')}}">
                        <div class="row m-t-sm">
                            <div class="col-sm-9 m-b-xs">
                            </div>
                            <div class="col-sm-3 m-b-xs">
                                <div class="input-group">
                                    <input class="input-sm" name="card" value="{{ old('card') }}" placeholder="请输入卡号" type="text">
                                    <span class="input-group-btn">
                                        <button class="btn btn-sm btn-default" type="submit" title="搜索">
                                            <i class="glyphicon glyphicon-search"></i> 搜索
                                        </button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </form>
                </header>
                <section class="scrollable  wrapper w-f">
                    <section class="panel panel-default">
                        <div class="table-responsive">
                            <table class="table table-hover m-b-none entity-view" data-path="/attendance/count/countDetail/id/{0}">
                                <thead>
                                <tr>
                                    <th style="text-align: center;">序号</th>
                                    <th style="text-align: center;">实体卡卡号</th>
                                    <th style="text-align: center;">密码</th>
                                    <th style="text-align: center;">状态</th>
                                    <th style="text-align: center;">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach ($res as $k=>$v)
                                    <tr>
                                        <td style="text-align: center;">{{$limit*($res->currentPage()-1)+$k+1}}</td>
                                        <td style="text-align: center;">{{$v->card_num}}</td>
                                        <td style="text-align: center;">{{$v->password}}</td>
                                        <td style="text-align: center;"><?php $arr=[0=>'未锁定',1=>'已锁定']?>{{$arr[$v->lock]}}</td>
                                        <td style="text-align: center">
                                            <a class="label label-danger unbind-printer act"  data-id="{{$v->id}}" >解锁</a>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </section>
                    <div style="text-align: center">{!! $res->appends($_GET)->render() !!}</div>
                </section>

            </section>
        </aside>
    </section>

@endsection

@section('addscript')
    <script>
        $(function(){
            $(".act").click(function() {
                var url = "{{ url('admin/card/unlock') }}";
                var id = $(this).data('id');
                $.ajax({
                    'url': url,
                    'type': "post",
                    'data': {id: id},
                    'dataType': 'json',
                    'success': function (data) {
                        if (data.success) {
                            location.reload();
                        } else {
                            layer.alert(data.msg)
                        }
                    }
                })
            })
        });
    </script>
@endsection
